/*
 * atmega_adc.c
 *
 * Created: 4/4/2011 17:03:26
 *  Author: morpheus
 */ 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/portpins.h>


#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <util/delay.h>

#include "ServoTimeTimer1.h"
/*

http://extremeelectronics.co.in/avr-tutorials/servo-motor-control-by-using-avr-atmega32-microcontroller/

*/
int main()
{
  ServoTimeTimer1 servo;

  servo.attach(PB2);

  uint8_t count = 10; 
  while(1)
  {

    for(;count < 180;++count)
    {
      servo.write_deg(count);
      _delay_ms(5);
    }

    for(;count > 0; --count)
    {
      servo.write_deg(count);
      _delay_ms(4);
    }

    // left
    //servo.write_ms(500);
    //_delay_ms(100);
    // left
    //servo.write_deg(0);
    //_delay_ms(500);

    // center
    //servo.write_deg(1500);
    //_delay_ms(100);

    // center
   // servo.write_deg(95);
    //_delay_ms(500);

    // right
    //servo.write_ms(2500);
    //_delay_ms(100);

    // right
    //servo.write_deg(180);
    //_delay_ms(2500);

    _delay_ms(100);
  }



  return 0;
  

}
